﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PB.Airsoft.Web.Business.Interfaces;
using PB.Airsoft.Core.Unity;
using System.Diagnostics;
using PB.Airsoft.Business.User.Interfaces;
using System.Web;
using PB.Airsoft.Business.User;
using PB.Airsoft.Business.Account;
using PB.Airsoft.Business.Utilities.Caching;

namespace PB.Airsoft.Web.Business
{
    public class AppContext : IAppContext
    {
        public static IAppContext Current
        {
            [DebuggerStepThrough]
            get { return IoC.GetInstance<IAppContext>(); }
        }

        public IUser User
        {
            get
            {
                if (!HttpContext.Current.User.Identity.IsAuthenticated)
                    return null;

                string email = HttpContext.Current.User.Identity.Name;
                return UserManager.GetUser(AccountManager.GetUserAccountByEmail(email).UserId);
            }
        }
    }
}
